package com.woniuxy.controller;

import com.woniuxy.entity.Product;
import com.woniuxy.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author: 曾令忠
 * @Description:
 * @Date: 2020/7/2 0002-下午 3:11
 */
@Controller
@RequestMapping("/product")
public class ProductController {
    @Autowired
    ProductService productService;

    @RequestMapping("/all")
    @ResponseBody
    public List<Product> getAll(){
        return productService.getAll();
    }

    @RequestMapping("/find")
    @ResponseBody
    public Product getProductById(int pid){
        System.out.println(pid);
        return productService.findProductyId(pid);
    }

    @RequestMapping("/del")
    @ResponseBody
    public int delProductById(int id) throws NoSuchMethodException {
        return productService.delById(id);
    }

}
